import random

size = [22, 22]


def creatPoint(seed):
    """返回随机元素"""
    return random.choice([1, 4, 5, 6, 7, 8])


def creatLine():
    """创建一行"""
    line = [1] * 10
    while True:
        line = [creatPoint(x) for x in range(size[0])]
        if line.count(8) > 10:
            continue
        elif line.count(7) > 2:
            continue
        elif line.count(6) > 10:
            continue
        elif line.count(5) > 15:
            continue
        elif line.count(4) > 20:
            continue
        else:
            break
    return line


def creatMaps():
    """创建地图"""
    maps = [creatLine() for line in range(size[1])]

    # for x in range(0, size[0], 2):
    #     for y in range(0, size[1], 2):
    #         print(x, y)

    # AI出生点左
    maps[0][0] = 1
    maps[0][1] = 1
    maps[1][0] = 1
    maps[1][1] = 1
    # AI出生点中
    maps[0][int(size[0] / 2)] = 1
    maps[0][int(size[0] / 2) - 1] = 1
    maps[1][int(size[0] / 2)] = 1
    maps[1][int(size[0] / 2) - 1] = 1
    # AI出生点右
    maps[0][-1] = 1
    maps[0][-2] = 1
    maps[1][-1] = 1
    maps[1][-2] = 1
    # Player基地
    maps[-1][int(size[0] / 2)] = 9
    maps[-1][int(size[0] / 2) - 1] = 9
    maps[-2][int(size[0] / 2)] = 9
    maps[-2][int(size[0] / 2) - 1] = 9
    # Player基地护墙
    maps[-1][int(size[0] / 2) - 2] = 4
    maps[-1][int(size[0] / 2) + 1] = 4
    maps[-2][int(size[0] / 2) - 2] = 4
    maps[-2][int(size[0] / 2) + 1] = 4
    maps[-3][int(size[0] / 2) - 2] = 4
    maps[-3][int(size[0] / 2) - 1] = 4
    maps[-3][int(size[0] / 2)] = 4
    maps[-3][int(size[0] / 2) + 1] = 4
    # Player出生点A
    maps[-1][int(size[0] / 2) - 3] = 1
    maps[-1][int(size[0] / 2) - 4] = 1
    maps[-2][int(size[0] / 2) - 3] = 1
    maps[-2][int(size[0] / 2) - 4] = 1
    # Player出生点B
    maps[-1][int(size[0] / 2) + 3] = 1
    maps[-1][int(size[0] / 2) + 2] = 1
    maps[-2][int(size[0] / 2) + 3] = 1
    maps[-2][int(size[0] / 2) + 2] = 1
    return maps


def Hello():
    print(
        """
    Hello test map          
"""
    )


if __name__ == "__main__":
    print("Hello")
    while True:
        Hello()
        cmd = input(">")
        if cmd == "quit":
            break
        elif cmd == "c":
            maps = creatMaps()
            for i in maps:
                print(i)
    print("Bye")
